package tom.jiafei;
import java.sql.*;
import java.io.*;
public class Shopping{
	String userid;
	String[][] shoppingList;
	String s="00";
	public void setUserid(String str){
		userid=str;
	}
	public String getUserid(){
		return userid;
	}
	public void getShoppingList(){
		Connection con;
	    Statement sql;
	    ResultSet rs;
	    try{
	    	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	    	}
	    catch(Exception e){s="11";}
   
    try{
		String uri = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=book_store";
		String user = "sa";
		String password = "sa";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		rs=sql.executeQuery("SELECT * from shopping where userid="+"'"+userid+"'");
		int r=0;
		String[] str={"1","2","3"};
		while(rs.next()){	
			for(int i=0;i<3;i++){
				str[i]=rs.getString(i+1);	}	
			shoppingList[r]=str;
			r++;			
		}
		con.close();
	}
	catch(SQLException e1){s="22";}
	//return shoppingList;
	}	
	public String getS(){
		return s;
	}
	
	
	
	
	
	
	
	
}